package blaha.genalg.staticmethods;

import org.apache.log4j.Logger;


import blaha.logging.Log;

/**
 * Count combination on two numbers
 * @author peta
 *
 */
public class Combination {
	
	private static final Logger log  = Log.getLoggerMoje();

	public static int comb(int n, int k) {
		if(k>n){
			log.error("k>n pro hodnoty:k="+k+" n="+n);
			return 0;
		}
		int m= Math.min(n-k, k);
			
		int c= 1;
		for (int i= 1; i <= m; i++) {
			c*= n--; c/= i;
		}
			
		return c;
	}
	
	public static int test(int mensi, int cislo){
		int nn = 0;
		
		for(int i=mensi;i<=cislo;i++)
			nn+=i;
		
		return nn;
	}

}
